﻿using System;

namespace FastCode
{


    public static class DbTypeConverter
    {
        public static Type ConvertStringTypeToCSharpType(string dbType)
        {
            switch (dbType.ToLower())
            {
                case "varchar":
                case "nvarchar":
                case "char":
                case "nchar":
                case "text":
                case "ntext":
                case "xml":
                    return typeof(string);
                case "int":
                case "integer":
                    return typeof(int);
                case "bigint":
                    return typeof(long);
                case "smallint":
                    return typeof(short);
                case "tinyint":
                    return typeof(byte);
                case "float":

                    return typeof(double);
                case "bit":
                    return typeof(bool);
                case "datetime":
                case "date":
                case "datetime2":
                    return typeof(DateTime);
                case "decimal":
                case "numeric":
                case "money":
                    return typeof(decimal);
                // 添加其他字符串类型对应的 C# 类型转换
                default:
                    throw new NotSupportedException($"Conversion from string type '{dbType}' is not supported.");
            }
        }
    }

}
